const mongoose = require('mongoose')
const {formatDate} = require('../utils/utils')
const schema = new mongoose.Schema({
  //轮播图
  carousel: {
    type: String,
    required: [true, '图片地址必填']
  },
  // 是否现在使用
  is_use: {
    type: Boolean,
    required: [true, '图片地址必填'],
    default: false
  },
  //更新日期
  date: {
    type: mongoose.SchemaTypes.Date,
    default: Date.now,
    get(val) {
      return formatDate(new Date(val), 'yyyyMM月dd日 hh:mm:ss')
    }
  }
})

module.exports = mongoose.model('Banner', schema)
